import { NH6 } from "naive-ui";
import { getSlotsDom } from "../utils";
import type { HTMLAttributes } from "vue";
import type { BaseComponentType } from "../types";
import type { H6Props } from "naive-ui";
export type H6FactoryConstructorType = {
  props?: H6Props;
  attrs?: HTMLAttributes;
  defaultSlot?: BaseComponentType;
};
export class H6Factory {
  private attrs: HTMLAttributes = {};
  private props: H6Props = {};
  private defaultSlot: BaseComponentType = null;
  constructor(data?: H6FactoryConstructorType) {
    if (data?.props) this.setProps(data.props);
    if (data?.attrs) this.setAttrs(data.attrs);
    if (data?.defaultSlot) this.setDefault(data.defaultSlot);
  }
  setAttrs(attrs: HTMLAttributes) {
    this.attrs = attrs;
    return this;
  }
  setProps(props: H6Props) {
    this.props = props;
    return this;
  }
  setDefault(component: BaseComponentType) {
    this.defaultSlot = component;
    return this;
  }
  create() {
    return (
      <NH6 {...this.attrs} {...this.props}>
        {{
          default: () => getSlotsDom(this.defaultSlot),
        }}
      </NH6>
    );
  }
}
